<!doctype html>
<html>
@include('top.title')
<body>
<style>
    .text > p > img {
        width: 100%;
        height: 100%;
    }
</style>
@include('top.header')
@if(!empty(session('success')))
    <div id="tishi"
         style="background-color: #caeaca;position:absolute; margin:840px 2px 4px 1580px;width:300px;height: 24px;padding:10px;border-radius: 50px;">
        <span style="text-align: center;display:block;"> 提示信息：{{session('success')}}</span>
    </div>
@endif
<div class="mainContent">
    @include('top.menu')
    <div class="blogitem">
        <article>
            <h2 style="margin-top: 10px">
                <img style="width: 50px;height:50px;border-radius:25px;" src="{{$list['url']}}"
                     alt="{{$list['title']}}">
                <a href="/">{{$list['title']}}</a>
            </h2>
            <ul class="text">
                <?=$list['content']?>
            </ul>
            <div class="textfoot">
                <span style="color:#a6a6a6;">发表时间:{{$list['add_time']}}</span>
                <span style="cursor:pointer" onclick="zan()">赞 <span style="color: #ff8b70;"
                                                                     id="zans">{{$zan}}</span></span>
                <form action="/article/{{$list['article_id']}}" method="post">
                    {{ csrf_field() }}
                    {{ method_field('DELETE') }}
                    <input style="float: right;margin: -20px 888px 0 0;background-color:rgba(0,0,0,0);border: 0;color: #a6a6a6;"
                           onclick="del();" type="submit" value="删除">
                </form>
            </div>
        </article>
        <form action="/article" method="post">
            {{ csrf_field() }}
            <input type="hidden" name="id" value="{{$list['article_id']}}">
            <div style="text-align:center;">
                <textarea name="comment" id="" cols="102" rows="6"
                          style="background-color: #f7fafb;width: 1183px;padding:10px" maxlength="500"
                          placeholder="我也来说两句。。。。。"></textarea>
                <button type="submit" style="color: #ff8b70;text-align:center;width: 1206px;margin-bottom: 15px">评论
                </button>
            </div>
        </form>
        @foreach($comment as $k=>$v)
            <div style="margin: 0 auto;width:1204px;">
                <span>
                    <img style="width:40px;height:40px;margin-right: 5px;border-radius:25px;" src="{{$v['url']}}"
                         alt="{{$v['content']}}">
                </span>
                <span style="color: red;">({{$v['add_time']}}){{$v['name']}}说：</span>
                <div style="margin-left: 60px;width: 1059px;word-break: break-all"><?=$v['content']?></div>
                {{--<span style="float: right" id="a">--}}
                    {{--<span id="huifu"style="cursor:pointer" onclick="$('#ReNL').show()">回复</span>--}}
                    {{--<span style="cursor:pointer">删除</span>--}}
                {{--</span>--}}
                {{--<div id="ReNL" style="text-align: center;margin: 0 auto;">--}}
                    {{--<div style="color: #a2a0a0;cursor:pointer">回复{{$v['name']}}：</div>--}}
                    {{--<div><textarea name="comment" id="" cols="10" rows="1"--}}
                                   {{--style="background-color: #f7fafb;width: 1000px;padding:10px"--}}
                                   {{--maxlength="500"></textarea></div>--}}
                    {{--<div style="float: right;margin-right: 100px">--}}
                        {{--<span style="cursor:pointer">回复</span>--}}
                        {{--<span id="shouqi" style="cursor:pointer" onclick="$('#ReNL').hide()">收起</span>--}}
                    {{--</div>--}}
                {{--</div>--}}
            </div>
        @endforeach
    </div>
</div>
@include('top.footer')
<div id="login" hidden
     style="background-color: #caeaca;position:absolute; margin:-220px 2px 4px 1580px;width:300px;height: 24px;padding:10px;border-radius: 50px;">
    <a href="/login" style="text-align: center;display:block;">提示信息：请先登录！</a>
</div>
</body>
</html>
<script type="text/javascript">
    function del() {
        if (!confirm("确认删除吗")) {
            event.preventDefault();
        }
    }
    function zan() {
        $.ajax({
            type: 'post',
            url: "{{url('/article/zan')}}",
            data: {"article_id":{{$list['article_id']}}, '_token': "{{csrf_token()}}"},
            dateType: "json",
            headers: {
                'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
            },
            success: function (result) {
                if (result.status == 'true') {
                    document.getElementById("zans").innerHTML = result.val;
                } else if (result.status == 'login') {
                    $("#login").show();
                } else {
                    document.getElementById("zans").innerHTML = result.val;
                }
            }
        })
    }
</script>